package org.dtrd.modules.record.util;

/**
 * @author 萧
 * @date:2021-10-03 7:18 下午
 **/
public enum TimePeriod {

    /**
     * 全部
     */
    ALL(0, Integer.MIN_VALUE),
    /**
     * 一周
     */
    WEEK(1, -6),
    /**
     * 两周
     */
    TWOWEEKS(2, -13),
    /**
     * 一月
     */
    MONTH(3, -29),
    /**
     * 两月
     */
    TWOMONTHS(4, -59),
    /**
     * 三月/季度
     */
    QUARTER(5, -89),
    /**
     * 半年
     */
    HALF_YEAR(6, -179),
    /**
     * 一年
     */
    YEAR(7, -364);

    private int period;
    private int duration;

    TimePeriod(int period, int duration) {
        this.period = period;
        this.duration = duration;
    }

    public int getPeriod() {
        return period;
    }

    public void setPeriod(int period) {
        this.period = period;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public static TimePeriod valueOf(Integer period) {
        for (TimePeriod value : values()) {
            if (value.period == period) {
                return value;
            }
        }
        return null;
    }


}
